package service

import (
	"context"
	"verify-code/internal/biz"

	pb "verify-code/api/customer"
)

type CustomerService struct {
	uc *biz.CustomerUsecase
	pb.UnimplementedCustomerServer
}

func NewCustomerService(uc *biz.CustomerUsecase) *CustomerService {
	return &CustomerService{uc: uc}
}

func (s *CustomerService) GetVerifyCode(ctx context.Context, req *pb.GetVerifyCodeReq) (*pb.GetVerifyCodeReply, error) {
	code, err := s.uc.GenerateVerifyCode(context.Background(), req.Telephone)
	if err != nil {
		return nil, err
	}
	return &pb.GetVerifyCodeReply{Code: 200, Message: "success", Data: code}, nil
}
